<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<%@include file="/survey/include/head.jsp"%>
<body onload="isObtype()">
<div id="demo">
    <div id="mainbox">
        <div id="box">
<%@include file="/survey/include/top.jsp"%>
           <div class="right">
                <div class="banner"><img src="<%=request.getContextPath() %>/survey/images/about_banner.jpg" width="703" height="183" /></div>
             <div class="tj_news" style="float:left; width:97%;">
               <h1>添加调查资料</h1><a name="question"></a>
               <div class="dd">
  <form  method="post" action="<%=request.getContextPath() %>/symanage/objectable/editobj.htm" onsubmit="return check()">
<p> <span class="STYLE2"> 资料名称:</span>
<input type="hidden" value="${tobj.sy_id }" name="sy_id">
<input type="hidden" value="${tobj.id }" name="id">
                  <label>
                  <input name="ob_name" type="text" id="ob_name" value="${tobj.ob_name }" size="20" onBlur="ob_onblur()"/>
                  </label>
              </p>
              
<script type="text/javascript" src="<%=request.getContextPath() %>/symanage/js/pingyin.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/symanage/js/checkval.js"></script>
  <script type="text/javascript">
  function ob_onblur(){
	/*   <!-- 汉字转拼音   -->    */
	  var ob_name=document.getElementById("ob_name").value;
	var p = pinyin.go(ob_name); 
	document.getElementById("ob_code").value=p;
	}
  
  function check(){
	  var ob_size = document.getElementById("ob_size").value;
	  var ob_code = document.getElementById("ob_code").value;
	  if(!isNum(ob_size,"资料长度"))
		  return false;
	 
	  if(!isLetter(ob_code)){
		  return false;
	  }
	
	  return true;
  }
  
  function ob_str(obj){
	  if(obj.value==3){
		  document.getElementById("ob_size").value="23";
		  document.getElementById("ob_size").readonly="readonly";
		  document.getElementById("ob_size").style="background-color:#cccccc";
	  }
	  else if(obj.value==5) {
		  document.getElementById("ob_size").value="18";
	  	  document.getElementById("ob_size").readonly="readonly";
		  document.getElementById("ob_size").style="background-color:#cccccc";
	  }
	  else{
		  document.getElementById("ob_size").style="background-color:#ffffff";
	  }
	  changeTextState(obj.value);
	}
		
		 
  //编辑默认值的状态格式
  function changeTextState(ob){
  	var objtx = document.getElementById("df_text");
  	var objta = document.getElementById("df_textarea");
	var inputtx = document.getElementById("tx_default");
	var inputta = document.getElementById("ta_default");
  	if(ob==7){
	  	objtx.style.display="none";
	  	objta.style.display="";
		inputtx.disabled=true;
		inputta.disabled=false;
	}else{
	  	objtx.style.display="";
	  	objta.style.display="none";
		inputtx.disabled=false;
		inputta.disabled=true;
	}
  }
 
  function chageDefault(obj){
     alert(obj.value);
     document.getElementById("ob_default").value=obj.value;
  }
  
  function isObtype(){
  	var isObtype='${tobj.ob_type}';
  	changeTextState(isObtype);
  }
</script>
<p>&nbsp;</p>
<p class="STYLE2">资料类型:
  <label>
  <select name="ob_type" size="1" id="ob_type" value="${tobj.ob_type}" onchange="ob_str(this)">
    <option value="1" <c:if test="${tobj.ob_type=='1'}">selected</c:if>>字符串</option> <!-- selected="selected" -->
    <option value="2" <c:if test="${tobj.ob_type=='2'}">selected</c:if>>数字</option>
    <option value="3" <c:if test="${tobj.ob_type=='3'}">selected</c:if>>时间类型</option>
    <option value="4" <c:if test="${tobj.ob_type=='4'}">selected</c:if>>大文本</option>
    <option value="5" <c:if test="${tobj.ob_type=='5'}">selected</c:if>>身份证</option>
    <option value="6" <c:if test="${tobj.ob_type=='6'}">selected</c:if>>上传图形</option>
    <option value="7" <c:if test="${tobj.ob_type=='7'}">selected</c:if>>参数选择</option>
  </select>
  </label>
</p>
<p class="STYLE2">&nbsp;</p>
<p class="STYLE2">资料长度:
  <label>
  <input name="ob_size" type="text" id="ob_size" value="${tobj.ob_size }" size="20" />
  </label>
</p>
<p class="STYLE2">&nbsp;</p>
<p class="STYLE2">字段编码:
  <label>
  <input name="ob_code" type="text" id="ob_code" value="${tobj.ob_code }" size="20" />
  </label>
</p>
<p class="STYLE2">&nbsp;</p>
<!-- 默认值 -->
<div id="df_text">
<p class="STYLE2">&nbsp;&nbsp;默认值 :
  <label>
  <input name="ob_default" type="text" id="tx_default" value='<c:if test="${tobj.ob_type!='7'}">${tobj.ob_default }</c:if>' size="20"/>
  </label>
</p>
</div>
<!-- 默认值 -->
<div id="df_textarea" style="display:none;">
<p class="STYLE2">&nbsp;&nbsp;默认值 :
  <label>
  <textarea rows="5" cols="45" id="ta_default" name="ob_default">${tobj.ob_default }</textarea>如果是参数形式，请按照换行的格式填写选择项。
  </label>
</p>
</div>   

  <p class="STYLE2">&nbsp;</p>
<p class="STYLE2">资料排序:
  <label>
  <input name="ob_order" type="text" id="ob_order" value="${tobj.ob_order }" size="20" />
  </label>
</p>
<p class="STYLE2">&nbsp;</p>
<p class="STYLE2">字段状态:
  <label>
  <select  name="ob_isuse" type="text" id="ob_isuse">
  <option value="0" <c:if test="${tobj.ob_isuse=='0' }">selected</c:if>>启用</option>
  <option value="1" <c:if test="${tobj.ob_isuse=='1' }">selected</c:if>>停用</option></select> 
  </label>
</p>

<p>&nbsp;</p>
<p align="justify" class="STYLE2"> 
  <label></label>
</p>
<p align="center" class="STYLE2">
  <label></label>
  <label></label>
</p>
      <input type="submit" name="button" id="button" value="确认提交" />
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
     <input type="button" name="reset" id="button2" value="返回" onclick="location.href='<%=request.getContextPath() %>/symanage/baseinfo/list.htm'">   
<p>&nbsp;</p>
</form>
<table width="700" border="1">
  <tr>
   <td width="64"><div align="center">资料名称</div></td>
    <td width="60"><div align="center">资料类型</div></td>
    <td width="30"><div align="center">资料长度</div></td>
    <td width="120"><div align="center">字段编码</div></td>
    <td width="200"><div align="center">默认值</div></td>
    <td width="30">资料排序</td>
    <td width="30"><div>启用</div></td>
    <td width="120"><div align="center">所属问卷</div></td>
     <td width="129"><div align="center">操作</div></td>
  </tr>
  <c:forEach var="ls" items="${ls}">
  <tr>
    <td><label> ${ls.ob_name }</label></td>
    <td><label>  ${obtype[ls.ob_type] }</label></td>
    <td>${ls.ob_size }</td>
    <td>${ls.ob_code }</td>
    <td>${ls.ob_default }</td>
    <td>${ls.ob_order }</td>   
    <td><c:if test="${ls.ob_isuse=='0'}">启用</c:if><c:if test="${ls.ob_isuse=='1'}">停用</c:if></td> 
    <td>${bs.sy_name }</td>
    <td align="center">
    <a href="#" onclick="if(confirm('您确认删除该资料对象吗？')){location.href='deleobj.htm?id=${ls.id}&sy_id=${ls.sy_id}'}"><img src="<%=request.getContextPath() %>/symanage/js/kindeditor/plugins/image/images/del.png"></a>
     <a href="eidobj.htm?id=${ls.id }" ><img src="<%=request.getContextPath() %>/symanage/js/kindeditor/plugins/image/images/edit.png" ></a>
    <a href="#" onclick="if(confirm('您确认更改当前状态？')){location.href='isuse.htm?id=${ls.id}'}">
    <c:if test="${ls.ob_isuse=='1'}"><img src="<%=request.getContextPath() %>/symanage/js/kindeditor/plugins/image/images/star.png" title="启用"></c:if>
    <c:if test="${ls.ob_isuse=='0'}"><img src="<%=request.getContextPath() %>/symanage/js/kindeditor/plugins/image/images/stop.png" title="停用"></c:if></a>
	</td>
  </tr>
  </c:forEach>
</table>
 <p>&nbsp;</p>
 <p>&nbsp;</p>
                 </div>
                </div>
                <div class="clear"></div>
		</div>
            <div class="clear"></div>
<%@include file="/survey/include/bottom.jsp"%>
        </div>
    </div>
</div>
</body>
</html>

